package com.sky.controller.admin;

import com.sky.result.Result;
import com.sky.service.WorkSpaceService;
import com.sky.vo.BusinessDataVO;
import com.sky.vo.DishOverViewVO;
import com.sky.vo.OrderOverViewVO;
import com.sky.vo.SetmealOverViewVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;

@RestController
@RequestMapping("/admin/workspace")
public class WorkSpaceController {

    @Autowired
    public WorkSpaceService workSpaceService;

    /**
     * 功能描述: 工作台显示订单数量
     *
     * @return : com.sky.result.Result<com.sky.vo.OrderOverViewVO>
     */
    @GetMapping("/overviewOrders")
    public Result<OrderOverViewVO> orders() {
        OrderOverViewVO orderOverViewVO = workSpaceService.showCountOrder();
        return Result.success(orderOverViewVO);
    }

    /**
     * 功能描述: 工作台显示菜品
     *
     * @return : com.sky.result.Result<com.sky.vo.DishOverViewVO>
     */
    @GetMapping("/overviewDishes")
    @ApiOperation("菜品停启售数量显示")
    public Result<DishOverViewVO> showCountDishs() {
        DishOverViewVO dishOverViewVO = workSpaceService.showCountDishs();
        return Result.success(dishOverViewVO);
    }


    /**
     * 功能描述: 工作台展示套餐
     *
     * @return : com.sky.result.Result<com.sky.vo.SetmealOverViewVO>
     */
    @GetMapping("/overviewSetmeals")
    public Result<SetmealOverViewVO> showCountSetmeal() {
        SetmealOverViewVO setmealOverViewVO = workSpaceService.showCountSetmeal();
        return Result.success(setmealOverViewVO);
    }

    /**
     * 功能描述: 工作台展示数据
     *
     * @return : com.sky.result.Result
     */
    @GetMapping("/businessData")
    public Result showBusinessData() {
        LocalDateTime end = LocalDateTime.now().with(LocalTime.MAX);
        LocalDateTime begin = LocalDateTime.now().with(LocalTime.MIN);
        BusinessDataVO businessDataVO = workSpaceService.businessData(begin, end);
        return Result.success(businessDataVO);
    }
}
